import { getInfo, setInfo} from '@/utils/storage'

export default {
    namespaced: true,
    state () {
        return {
            // 个人权限认证相关
            userInfo: getInfo()
        }
    },
    getters: {
    },
    mutations: {
        // 所有mutations 的第一个参数都是 state
        setUserInfo (state, obj) {
            state.userInfo = obj
            setInfo(obj)
        }
    },
    actions: {
        logout(context) {
            // 个人信息要重置
            context.commit('setUserInfo', {})

            // 购物车信息要重置 ( 跨模块调用mutations ) cart/setCartList
            context.commit('cart/setCartList', [], { root: true })
        }
    }
}